﻿using System;
using System.Threading;
using TestClientsCommon;
using smp.RabbitMq;

namespace Publisher1
{
    class Program
    {
        static void Main(string[] args)
        {
            var factory = new RabbitMqFactory();
            using(var publisher = factory.CreatePublisher("pub1"))
            {
                var messageNumber = 0;
                while(true)
                {
                    messageNumber++;
                    publisher.Publish(new Message1
                                          {
                                              Id = Guid.NewGuid(),
                                              Number = messageNumber,
                                              Sent = DateTime.Now,
                                              Text = "Sent message " + messageNumber + "by Publisher 1"
                                          });
                    Console.WriteLine("Published message number " + messageNumber);
                    Console.WriteLine();
                    Thread.Sleep(1000);
                }
            }
        }
    }
}
